<%= render  :partial => "apo/navigation" %>

<div id="containerBody">

	<div style="margin-bottom: 0.5em">
  	<% form_tag({:action => "officers"}, {:style => "display: inline"}) do -%>
			<% unless params[:semester].nil? %>
				<%= select "semester", "index", @semesters, {:selected => params[:semester][:index].to_i}, {:onchange => 'this.form.submit();'} -%>
			<% else %>
				<%= select "semester", "index", @semesters, {}, {:onchange => 'this.form.submit();'} -%>
			<% end -%>
		<% end %>
		<% if session[:user].admin? %>
				<% form_tag({:controller => "positions", :action => "create", :id => params[:id]}, {:style => "display: inline"}) do -%>
					<%= submit_tag "Add officer" -%>
				<% end -%>
		<% end %>
		</div>
	<div style="clear: both"></div>

	<% categories = 0 %>
	<% @members.each_with_index do |member, index| %>
		<% if categories == 0 %>
			<% categories = 1 %>
			<div style="float: left; margin-right: 1em; width: 30%">
				<h3>Exec Officers</h3>
				<div class="container memberInfoContainer" style="margin-bottom: 1em;">

		<% elsif categories == 1 and member.position > 100 %>
			<% categories = 2 %>
				</div>
			</div>
			<div style="float: left; margin-right: 1em; width: 30%">
				<h3 style="clear: left;">Appointed Officers</h3>
				<div class="container memberInfoContainer" style="margin-bottom: 1em;">
		<% elsif categories == 2 and member.position > 300 %>
			<% categories = nil %>
				</div>
			</div>
			<div style="float: left; width: 30%">
				<h3 style="clear: left;">Pledge Officers</h3>
				<div class="container memberInfoContainer">
		<% end %>
					<div class="cellRow cellRow<%= index%2+1 %>">
						<div class="cellBlock cellRowHeader">
							<% if session[:user].admin? %>
								<%= link_to h(Position.getPosition(member.position)), :controller => :positions, :action => :edit, :id => member %>:
							<% else %>
								<%= Position.getPosition(member.position) %>
							<% end %>
						</div>
						<div class="cellBlock"><%= link_to h(member.member.full_name), :action => :show, :id => member.member %></div>
					</div>
	<% end %>
				</div>

			</div>

</div>
